<template>
    <div>
        <div v-if="active==1">
            <el-form :inline="true" :model="params" class="demo-form-inline">
                <el-form-item label="挂号费用名称">
                    <el-input v-model="params.registeredfeeName" placeholder="挂号费用名称"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="search">查询</el-button>
                    <el-button type="primary" @click="toadd">添加</el-button>
                    <el-button type="primary" @click="pldel">批量删除</el-button>
                </el-form-item>
            </el-form>

            <el-table
                    :data="pageResult.records"
                    border
                    style="width: 100%"
                    @selection-change="handleSelectionChange">
                <el-table-column
                        type="selection"
                        width="55">
                </el-table-column>
                <el-table-column
                        fixed
                        prop="regId"
                        label="编号">
                </el-table-column>
                <el-table-column
                        label="医生姓名">
                    <template slot-scope="scope">
                        {{scope.row.hisDoctorEntity.trueName}}
                    </template>
                </el-table-column>
                <el-table-column
                        prop="registeredfeeName"
                        label="挂号费用名称">
                </el-table-column>
                <el-table-column
                        prop="registeredfeeFee"
                        label="金额">
                </el-table-column>
                <el-table-column
                        prop="registeredfeeSubFee"
                        label="子费用总钱数">
                </el-table-column>
                <el-table-column
                        prop="registeredfeeAggregateAmount"
                        label="挂号费用总金额">
                </el-table-column>
                <el-table-column
                        prop="numberofsub"
                        label="子费用数量">
                </el-table-column>
                <el-table-column
                        fixed="right"
                        label="操作">
                    <template slot-scope="scope">
                        <el-button @click="findson(scope.row.regId)" type="text" size="small">查看子费用</el-button>
                        <el-button @click="del(scope.row.regId)" type="text" size="small">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <el-footer class="case-exam-footer">
                <el-pagination
                        background
                        layout="prev, pager, next"
                        :total="pageResult.total"
                        :page-size="pageResult.size"
                        class="pagination"
                        @current-change="handleIndexChange"
                >
                </el-pagination>
            </el-footer>


            <el-dialog title="挂号费管理" :visible.sync="dialogFormVisibleAdd">
                <el-form :model="HisRegisteredfeeEntity">
                    <el-form-item label="挂号费用名称">
                        <el-input v-model="HisRegisteredfeeEntity.registeredfeeName" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="医生姓名">
                        <el-select v-model="HisRegisteredfeeEntity.mid" placeholder="医生姓名">
                            <el-option v-for="d in dockers"  :label="d.trueName" :value="d.uid" :key="d.uid"></el-option>
                        </el-select>
                    </el-form-item>
                    <el-form-item label="金额">
                        <el-input type="number" v-model="HisRegisteredfeeEntity.registeredfeeFee" autocomplete="off"></el-input>
                    </el-form-item>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="dialogFormVisibleAdd = false">取 消</el-button>
                    <el-button type="primary" @click="add()">确 定</el-button>
                </div>
            </el-dialog>

        </div>

        <div v-if="active==2">
            <registeredfee-sub :regId="regId" v-on:return="returnBtn" ></registeredfee-sub>
        </div>


    </div>
</template>

<script>

    import RegisteredfeeSub from './RegisteredfeeSub.vue'

    import Registeredfee from '../../model/mfy/HisRegisteredfee.js'
    const registeredfee = Registeredfee.getInstance();

    export default {
        name: "Registeredfee.vue",
        data(){
            return{
                pageResult:{}, //page对象
                params:{},     //高级查询参数对象
                dialogFormVisibleAdd:false,  // 控制 添加表单
                HisRegisteredfeeEntity:{}, //添加对象
                delVal:"",
                active:1,
                regId:'',
                dockers:[],
            }
        },
        methods : {
            list(){
                registeredfee.list(this.params).then(response=>{
                    this.pageResult = response.data.data
                })
            },
            handleIndexChange(index){
                this.params.page = index
                this.list()
            },
            search(){
                this.params.page=1
                this.list()
            },
            toupdate(regId){
                console.log(regId);
            },
            del(regId){
                registeredfee.del(regId).then(()=>{
                    this.list();
                })
            },
            pldel(){
                this.del(this.delVal)
            },
            handleSelectionChange(val){
                var PlDelArray =[];
                val.forEach(i=>{
                    PlDelArray.push(i.regId)
                })
                this.delVal=PlDelArray.join(",");
            },
            toadd(){
                this.HisRegisteredfeeEntity={}
              this.dialogFormVisibleAdd = true
            },
            add(){
                this.dialogFormVisibleAdd = false
                registeredfee.add(this.HisRegisteredfeeEntity).then(()=>{
                        this.list();
                })
            },
            dockerList(){
                registeredfee.dockerList().then((resp)=>{
                    this.dockers=resp.data.data;
                })
            },
            findson(regId){
                this.regId=regId
                this.active++;
            },
            returnBtn(){
                this.active--
            }
        },
        created() {
            this.list();
            this.dockerList();
        },
        components:{
            RegisteredfeeSub
        }
    }
</script>

<style scoped>

</style>
